package suit.ui;

public class FileChooser extends Box implements FileChooserDialog.Response {

	private Entry entry;
	private Button browse;

	private FileChooserDialog dialog;

	public FileChooser(int spacing) {
		super(Box.Horiz, false, spacing);
		entry = new Entry();
		browse = new Button("Browse...");
		pack(entry, true, true, 0);
		pack(browse, false, true, 0);

		browse.connect(new Button.Clicked() {

			public void onClicked(Button source) {
				dialog = new FileChooserDialog(screen);
				dialog.show();
			}
		});
	}
	
	public String getText() {
		return entry.getText();
	}

	protected boolean onExpose(Event e) {
		super.onExpose(e);
		return false;
	}

	public void onResponse(FileChooserDialog source) {
		entry.setText(source.getFilename());
	}

}
